package com.young.shop.admin.exceptions.handler;

import com.young.shop.admin.exceptions.BaseException;
import com.young.shop.pojo.vo.BaseRespVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@ControllerAdvice
@RestControllerAdvice
public class ExceptionsHandler {

	@ExceptionHandler(BaseException.class)
	@ResponseBody
	public BaseRespVO handlerExceptions(BaseException exception) {
		//todo 打印 warn 级别日志
		BaseRespVO result = new BaseRespVO();
		result.setCode(exception.getErrorCode());
		result.setMsg(exception.getMessage());
		return result;
	}
}
